<?php

	/*
	 *            ________ ___        
	 *           /   /   /\  /\       Konsolidate
	 *      ____/   /___/  \/  \      
	 *     /           /\      /      http://www.konsolidate.net
	 *    /___     ___/  \    /       
	 *    \  /   /\   \  /    \       Class:  CoreSystemBenchmark
	 *     \/___/  \___\/      \      Tier:   Core
	 *      \   \  /\   \  /\  /      Module: System/Benchmark
	 *       \___\/  \___\/  \/       
	 *         \          \  /        $Rev: 66 $
	 *          \___    ___\/         $Author: rogier $
	 *              \   \  /          $Date: 2008-02-04 18:01:47 +0000 (Mon, 04 Feb 2008) $
	 *               \___\/           
	 */


	/**
	 *  Simple benchmarking functions
	 *  @name    CoreSystemBenchmark
	 *  @type    class
	 *  @package Konsolidate
	 *  @author  Rogier Spieker <rogier@konsolidate.net>
	 */
	class CoreSystemBenchmark extends Konsolidate
	{
		protected $_timer;

		public function __construct( $oParent )
		{
			parent::__construct( $oParent );
			$this->_timer = Array();
		}

		public function start()
		{
			$this->_timer[] = microtime( true );
			return count( $this->_timer ) - 1;
		}

		public function stop( $nTimer=null )
		{
			if ( empty( $nTimer ) )
				$nTimer = count( $this->_timer ) - 1;
			if ( $nTimer < 0 || $nTimer >= count( $this->_timer ) )
				return false;
			return microtime( true ) - $this->_timer[ $nTimer ];
		}
	}

?>
